package cn.bdqn.fin.controller;

import cn.bdqn.fin.model.Approval;
import cn.bdqn.fin.service.ApprovalService;
import cn.bdqn.model.PageBean;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author gurilla
 * @create 2019-08-23 16:17
 */
@Controller
@RequestMapping("/fin/approval")
public class ApprovalController {
    @Resource
    private ApprovalService approvalService;

    @RequiresPermissions("fin:approval:page")
    @GetMapping
    public String topage(){
        return "/fin/approval";
    }

    @RequiresPermissions("fin:approval:list")
    @PostMapping("list")
    @ResponseBody
    public Object list(PageBean pageBean, String lname, String phone, String account, String drawee){
        return approvalService.list(pageBean, lname, phone, account, drawee);
    }

    @RequiresPermissions("fin:approval:save")
    @PostMapping("save")
    @ResponseBody
    public Object save(Approval approval){
        return approvalService.save(approval);
    }

    @GetMapping("getleader")
    @ResponseBody
    public Object getLeader(){
        return approvalService.getLeader().getData();
    }

    @GetMapping("getPaymentType")
    @ResponseBody
    public Object getPaymentType(){
        return approvalService.getPaymentType().getData();
    }

    @GetMapping("getApply")
    @ResponseBody
    public Object getApply(){
        return approvalService.getApply().getData();
    }
}
